/**
 * PHOSIDE: PHosphorylation Site IDentification Engine.
 * Copyright 2009 Digital Biology Lab, University of Missouri.
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version. <p/> This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more
 * details.
 */

package phoside.ui.task;

import phoside.PhosideClassify;
import phoside.Proteins;

import phoside.classify.result.PhosidePredictionResult;

import phoside.model.PhosideModel;

/**
 *
 */
public class PhosideClassifyTask extends AbstractTask {
    private final PhosideModel model;
    private final Proteins proteins;
    private final PhosideClassify classify;

    public PhosideClassifyTask(final PhosideModel model,
            final Proteins proteins, final PhosideClassify classify) {
        super("Phosphorylation prediction for "+model.getName());
        this.model = model;
        this.proteins = proteins;
        this.classify = classify;
    }

//    public PhosideClassifyTask(final PhosideModel model,
//            final Proteins proteins) {
//        this(model, proteins, -1, false);
//    }
//
//    public PhosideClassifyTask(final PhosideModel model,
//            final Proteins proteins, final int jobSize,
//            boolean selectivePrediction) {
//            super("Phosphorylation prediction for "+model.getName());
//            this.model = model;
//            this.proteins = proteins;
//            classify = new PhosideClassify();
//            classify.setJobSize(jobSize);
//            classify.setSelectivePrediction(selectivePrediction);
//    }

    /**
     * Executes Task.
     */
    //@Override
    public void run() {
            try {
                    taskMonitor.setPercentCompleted(-1);

                    taskMonitor.setStatus("Predicting...");
                    classify.setTaskMonitor(taskMonitor);

                    obj = classify.classify(model,proteins);

                    taskMonitor.setPercentCompleted(100);
                    taskMonitor.setStatus("Successfully predicted");

                    success = true;
            } catch (Exception e) {
                    taskMonitor.setPercentCompleted(100);
                    taskMonitor.setStatus("Failed to predict.\n"+e.getMessage());
                    e.printStackTrace();
                    return;
            }
    }

    public PhosidePredictionResult getResult() {
        return (PhosidePredictionResult)obj;
    }

}
